package com.example.boot.thread.demo.threaddemo.ThreadTest;

/**
 * @author wenyu
 */
public class Demo1  extends Thread{

    @Override
    public void run(){
        System.out.println(getName()+"是一个演员");
        int count = 1;
        boolean flag = true;
        while (flag ){
            System.out.println("这是演员"+getName()+"第"+count+"场表演");
            if(count%10==0){
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            if(count==100){
                flag = false;
            }
            count++;
        }
        System.out.println("演员"+getName()+"登台结束");

    }




    public static void main(String[] args) {
        Demo1 demo1 = new Demo1();
        demo1.setName("张三");
        demo1.start();


        Thread actress = new Thread(new Actress(),"武则天");
        actress.start();
    }


}

class  Actress implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"是一个演员");
        int count = 1;
        boolean flag = true;
        while (flag ){
            System.out.println("演员"+Thread.currentThread().getName()+"第"+count+"场表演");

            if(count%10==0){
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            if(count==100){
                flag = false;
            }
            count++;
        }
        System.out.println("演员"+Thread.currentThread().getName()+"登台结束");
    }
}
